package com.hsgene.discount.domain;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.hsgene.common.util.date.TimeJsonDeserializer;
import com.hsgene.common.util.validation.FieldChecker;
import com.hsgene.product.constants.PolicyType;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 优惠券
 */
public class GeneticDiscount {
    /**
     * 优惠券id
     */
    private String id;
    /**
     *满足条件金额
     */
    private BigDecimal conditionPrice;
    /**
     * 优惠的金额
     */
    private BigDecimal discountPrice;
    /**
     * 开始时间
     */
    @JsonDeserialize(using = TimeJsonDeserializer.class)
    private Date beginDateTime;
    /**
     * 结束时间
     */
    @JsonDeserialize(using = TimeJsonDeserializer.class)
    private Date endDateTime;
    /**
     *0不对外开放1对外开放
     */
    private Integer status;
    /**
     * 类型(1满减类型)
     */
    private Integer type;
    /**
     * 使用目标（1-全平台商品）
     */
    private Integer useTarget;
    /**
     * 可以获取积分
     */
    private Integer integral;
    /**
     *
     */
    private Integer deleteFlag;

    private String remarks;


    @JsonDeserialize(using = TimeJsonDeserializer.class)
    private Date createDateTime;
    @JsonDeserialize(using = TimeJsonDeserializer.class)
    private Date updateDateTime;

    private String description;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public BigDecimal getConditionPrice() {
        return conditionPrice;
    }

    public void setConditionPrice(BigDecimal conditionPrice) {
        this.conditionPrice = conditionPrice;
    }

    public BigDecimal getDiscountPrice() {
        return discountPrice;
    }

    public void setDiscountPrice(BigDecimal discountPrice) {
        this.discountPrice = discountPrice;
    }

    public Date getBeginDateTime() {
        return beginDateTime;
    }

    public void setBeginDateTime(Date beginDateTime) {
        this.beginDateTime = beginDateTime;
    }

    public Date getEndDateTime() {
        return endDateTime;
    }

    public void setEndDateTime(Date endDateTime) {
        this.endDateTime = endDateTime;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getUseTarget() {
        return useTarget;
    }

    public void setUseTarget(Integer useTarget) {
        this.useTarget = useTarget;
    }

    public Integer getIntegral() {
        return integral;
    }

    public void setIntegral(Integer integral) {
        this.integral = integral;
    }

    public Integer getDeleteFlag() {
        return deleteFlag;
    }

    public void setDeleteFlag(Integer deleteFlag) {
        this.deleteFlag = deleteFlag;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks == null ? null : remarks.trim();
    }

    public Date getCreateDateTime() {
        return createDateTime;
    }

    public void setCreateDateTime(Date createDateTime) {
        this.createDateTime = createDateTime;
    }

    public Date getUpdateDateTime() {
        return updateDateTime;
    }

    public void setUpdateDateTime(Date updateDateTime) {
        this.updateDateTime = updateDateTime;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * 字段校验
     */
    public void check(){
        FieldChecker.checkEmpty(this.type, "优惠券类型不能为空");
        FieldChecker.checkEmpty(this.discountPrice, "请输入优惠金额");
        FieldChecker.checkEmpty(this.conditionPrice, "请输入条件金额");
        FieldChecker.checkEmpty(this.beginDateTime, "请输入时间");
        FieldChecker.checkEmpty(this.endDateTime, "请输入时间");
    }
}